<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./lib/react.development.js"></script>
    <script src="./lib/react-dom.development.js"></script>
    <script src="./lib/babel.min.js"></script>
</head>
<body>
<div id="root">

</div>

</body>
<script type="text/babel">
    // jsx借助BABEL将其转换为浏览器可以识别的代码。
    // const root = ReactDOM.createRoot(document.querySelector("#root"));
    // root.render((
    //     <div>
    //         <p style={{color:"red"}}>1</p>
    //         <p>2</p>
    //     </div>
    // ));
</script>
<script>
    // 以下程序就是通过babel将上述程序转换以后的最终浏览器执行的代码
    "use strict";

    var root = ReactDOM.createRoot(document.querySelector("#root"));
    // 1
    // const virtualDOM = React.createElement("div", null,
    //     React.createElement("p", {
    //         style: {
    //             color: "red"
    //         }
    //     }, "1"),
    //     React.createElement("p", null, "2")
    // )


    const p1 =  React.createElement("p", {
        style: {
            color: "red"
        }
    }, "1");
    const p2 = React.createElement("p", null, "2");
    const virtualDOM = React.createElement("div", null,p1,p2);
    console.log(virtualDOM)
    root.render(virtualDOM);
</script>
</html>